<%@page import="com.is.control.TeacherAssessControl"%>
<%@page import="com.is.util.DateTime"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.is.model.TeacherAssess"%>
<%@page import="java.util.List"%>
<%@page import="com.is.util.ParamUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.servlet.TokenProcessor"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resources/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../../resources/js/jquery.artDialog.js"></script>
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<title>教职工考核</title>
</head>
<body>
<%
           int size = ParamUtil.getInt(request, "size",0);
           String token = ParamUtil.getString(request,"token","");
           String time = DateTime.SimpleDate();
           
           //AllowCommited判断是否允许提交
           if(size>0&&TokenProcessor.AllowCommited(request,token)){
                List<TeacherAssess> tas = new ArrayList<TeacherAssess>();
                for(int i=0;i<size;i++){
                    TeacherAssess ta = new TeacherAssess();
                    ta.setClassAmount(ParamUtil.getString(request, "classAmount"+i,"0.0"));
                    ta.setAbsentAmount(ParamUtil.getString(request,"absentAmount"+i,"0.0"));
                    ta.setExtraAmount(ParamUtil.getString(request,"extraAmount"+i,"0.0"));
                    ta.setLeaveAmount(ParamUtil.getString(request,"leaveAmount"+i,"0.0"));
                    ta.setCourseClassId(ParamUtil.getInt(request, "courseId"+i,0));
                    ta.setTime(time);
                    ta.setUid(ParamUtil.getInt(request, "uid"+i,0));
                    if(ta.getClassAmount().equals("0.0")&&ta.getExtraAmount().equals("0.0")&&ta.getLeaveAmount().equals("0.0")&&ta.getAbsentAmount().equals("0.0")){
                	   //除去所有为0.0的无效数据
                	    continue;
                    }
                    tas.add(ta);
                }
                if(TeacherAssessControl.insertTeacherAssess(tas)){  //同时会更新course_Class中realTotalClass的值
                 %>
        			   <script>
        			 //  $.dialog({content:'hello world!'});
				$.dialog({
						    title: '教师考核',
						    content: '系统已将你的考核情况记录',
						    icon: 'succeed',
						    ok: function(){
								window.location.href = "teacher_assess.jsp";
						    }
						});
        			   </script>
        			   <%
            	   }else{
            			   %>
            			   <script>
            			   $.dialog({
            				    title: '教师考核',
            				    content: '抱歉，系统出现错误或您录入的信息有误，本次录入信息均无效，请重试',
            				    icon: 'warning',
            				    ok: function(){
            				         history.go(-1);
            				    }
            				});
            			//   alert("抱歉，系统出现错误或您录入的信息有误，本次录入信息均无效，请重试");
            			  // history.go(-1);
            			   </script>
            			   <%
            	   }
                
           }else{
                     %>
            			   <script>
            			   $.dialog({
            				    title: '教师考核',
            				    content: '请不要重复提交,本次录入信息均无效，请重试',
            				    icon: 'error',
            				    ok: function(){
            				         history.go(-1);
            				    }
            				});
            			   </script>
            			   <%
           
           }
           

 %>
</body>
</html>